December Listing
         TTL "Speed/asm Sample pgm #8"
;
;
;
*********************************
*                               *
* Speed/asm sample program #8   *
*                               *
* Written by Randall Hyde       *
* Written on LISA v2.6          *
* 7/22/83                       *
*                               *
*********************************
;
;
;
;
**********************************
*                                *
* SPEED/ASM Equates              *
*                                *
**********************************
;
;
;
;
;
;
;
;
; GENERAL PURPOSE EQUATES
;
; The following variables are used
; by the SPEED/ASM package and
; shouldn't be used by the SPEED/ASM
; programmer.
;
;
;
;
FORASAV  EPZ 0
FORXSAV  EPZ FORASAV+1
FORYSAV  EPZ FORXSAV+1
FORZPG   EPZ FORYSAV+1
DESTADR  EPZ FORZPG+2
PTRADR   EPZ DESTADR+2
ISIMMED  EPZ PTRADR+2
OP       EPZ ISIMMED+1
MAXLEN   EPZ OP+2
VALUE    EPZ MAXLEN+1
DIGIT    EPZ VALUE+2
LEAD0    EPZ DIGIT+1
JMPADR   EPZ LEAD0+1
COUNT    EPZ JMPADR+2
GOTLN    EPZ COUNT+1
LINEINDX EPZ GOTLN+1
SIGN     EPZ LINEINDX+1
ACL      EPZ SIGN+1
ACH      EPZ ACL+1
XTNDL    EPZ ACH+1
XTNDH    EPZ XTNDL+1
AUXL     EPZ XTNDH+1
AUXH     EPZ AUXL+1
;
PROMPT   EPZ $33
RNDL     EPZ $4E
RNDH     EPZ $4F
STACK    EQU $100
INPUT    EQU $200
;
;
;
;
;
;
;
*************
* CONSTANTS *
*************
;
;
;
; The following symbols are constants
; for the values "FALSE", "TRUE", and
; Carriage Return (respectively).
;
; These symbols should only appear
; as inrtediate operands to a 6502
; instruction or in the operand field
; of a pseudo-opcode like BYT.
;
;
;
;
;
FALSE    EQU 0
TRUE     EQU 1
CR       EQU $8D
BELL     EQU $87
;
;
;
;
;
;
; "IF" STATEMENT EQUATES
;
; The following symbols should only
; be used in the ADR pseudo-opcode
; following a call to the SPEED/ASM
; IFx routines.
;
;
;
EQ       EQU "="
NE       EQU "#"
GT       EQU ">"
LT       EQU "<"
GE       EQU ">"|"="*256
LE       EQU "<"|"="*256
;
;
;
;
;
;
;
**************************
* SPEED/ASM ENTRY POINTS *
**************************
;
;
;
;
; NOTE: TOE EQUATE OF HJTC MUST
; BE CHANGED IF YOU RELOCATE
; SPEED/ASM TO SOME LOCATION
; OTHER THAN $7800
;
;
;
PUTC     EQU $7800
GETC     EQU PUTC+3
SAGL     EQU GETC+3          ; FOR USE BY S/A ONLY- SEE DOC.
SAPC     EQU SAGL+3          ;  "   "   "  "   "     "   "
HOME     EQU SAPC+3          ; HOME AND CLEAR
READLN   EQU HOME+3
INIT     EQU READLN+3
FOR      EQU INIT+3
FOR0     EQU FOR+3
NEXT     EQU FOR0+3
IFI      EQU NEXT+3
IFI0     EQU IFI+3
IFS      EQU IFI0+3
IFS0     EQU IFS+3
MOVE     EQU IFS0+3
LOAD     EQU MOVE+3
MOVS     EQU LOAD+3
LDSTR    EQU MOVS+3
PRINT    EQU LDSTR+3
PRTSTR   EQU PRINT+3
PRTINT   EQU PRTSTR+3
RDSTR    EQU PRTINT+3
RDINT    EQU RDSTR+3
ONXGOTO  EQU RDINT+3
CASE     EQU ONXGOTO+3
CASEI    EQU CASE+3
INSET    EQU CASEI+3
NOTINSET EQU INSET+3
ABS      EQU NOTINSET+3
NEG      EQU ABS+3
MUL      EQU NEG+3
DIV      EQU MUL+3
MOD      EQU DIV+3
RND      EQU MOD+3
SUBSTR   EQU RND+3
INDEX    EQU SUBSTR+3
LENGTH   EQU INDEX+3
CONCAT   EQU LENGTH+3
GETWZPG  EQU CONCAT+3        ;USED BY SPEED/ASM
RDFP     EQU GETWZPG+3
PRTE     EQU RDFP+3
PRTF     EQU PRTE+3
FADD     EQU PRTF+3
FSUB     EQU FADD+3
FMUL     EQU FSUB+3
FDIV     EQU FMUL+3
FLT      EQU FDIV+3
FIX      EQU FLT+3
FNEG     EQU FIX+3
FADDTN   EQU FNEG+3
FSUBTN   EQU FADDTN+3
FTIMES   EQU FSUBTN+3
FINTO    EQU FTIMES+3
IFF      EQU FINTO+3
MOVFP    EQU IFF+3
;
;
;
;
;
**********************************
**********************************
;
; Sample program #8 begins here.
;
;
START    JSR INIT            ;Always do first
;
MENULOOP JSR HOME
         JSR PRINT
         BYT "Speed/asm Sample Program #8",CR
         BYT CR,"Examples of various"
         BYT " menu programming",CR
         BYT "styles.",CR
         BYT CR
         BYT "Select one:",CR,CR
         BYT "  A) Straight menu selection",CR
         BYT "  B) Select values in a set",CR
         BYT "  C) Checking for values"
         BYT " not in a set",CR
         BYT CR
         BYT "Choice? :",0
;
;
; Read a character, if it is lcwer
; case convert it to upper case,
; then jump to the appropriate routine.
;
         JSR GETC
         CMP #"a"            ; See if lower case
         BLT >0
         AND #$DF            ; Converts it to upper
;
^0       CSP CASE,#NUMCAS0/3
CASES0   .DA "A",STDMENU
         .DA "B",SETSELCT
         .DA "C",NOTSTEXP
;
NUMCAS0  =   *-CASES0
;
;
;
; An invalid value was entered at
; this point.
;
         CSP PRINT
         BYT CR,CR,BELL,BELL
         BYT "Invalid entry, press return",CR,0
;
         JSR READLN
         JMP MENULOOP
;
;
;
;*************************************
;
;
; A standard menu selection is
; demonstrated here. Actually,
; the main menu is identical to
; this type of code.
;
STDMENU  JSR HOME
         CSP PRINT
         BYT CR,CR
         BYT "Standard Menu Selection",CR,CR
         BYT "  0: print 0",CR
         BYT "  1: print 1",CR
         BYT "  2: print 2",CR
         BYT " 55: print 55",CR,CR
         BYT "Choice? :",0
;
         CSP RDINT,SELCTVAR
;
         CSP CASEI,NUMCS1/4,SELCTVAR
CASES1   ADR 0,ZERO
         ADR 1,ONE
         ADR 2,TWO
         ADR 55,FIFTYFIV
;
NUMCS1   =   *-CASES1
;
;
; If the program gets to this point
; then they've entered an invalid
; value.
;
         CSP PRINT
         BYT BELL,BELL,CR
         BYT "Invalid entry, press return",CR,0
         JMP STDMENU
;
;
;********
;
; Control is transferred here if
; the user pressed 0.
;
ZERO     CSP PRINT,#CR,"You pressed zero",#CR,#0
         JMP QUITSTD
;
;
;********
;
; Control is transferred here if
; the user pressed 1.
;
ONE      CSP PRINT,#CR,"You entered 1",#CR,#0
         JMP QUITSTD
;
;
;********
;
; Control is transferred here if
; the user pressed 2.
;
TWO      CSP PRINT,#CR,"You entered 2",#CR,#0
         JMP QUITSTD
;
;
;********
;
; Control is transferred here if
; the user pressed 55.
;
FIFTYFIV CSP PRINT,#CR
         BYT "You entered fifty-five",CR,0
;
;
QUITSTD  CSP PRINT,#CR
         BYT "Press return to continue:"
         BYT 0
         JSR READLN
         JMP MENULOOP
;
;
;
;
;
;**********************************
;
; Demonstrate set selection with
; the INSET routine.
;
;
SETLOOP  JSR PRINT
         BYT CR,"Press return to continue:",0
         JSR READLN
;
SETSELCT JSR HOME
         JSR PRINT
         BYT "Enter an alphabetic or numeric",CR
         BYT "character (return quits):",0
;
         JSR GETC
         CMP #CR
         BNE >1
         JMP MENULOOP
;
; Convert lower case to upper case
;
^1       CMP #"a"
         BLT >0
         AND #$DF
;
^0:
;
;
;
;
; Note the sneaky way of specifying
; the number of elements in the sets.
; LISA's STR pseudo-opcode emits the
; length of the string that follows.
; This just happens to be the number
; of characters in the set. This only
; works if the set consists entirely
; of printable characters.
;
         JSR INSET
         STR "ABGDEFGHIUJKLMTOPQRSTUWXYZ"
         ADR ISALPHA
;
         JSR INSET
         STR "0123456789"
         ADR ISNUMRIC
;
;
; Non-alphanumeric character at this point.
;
         CSP PRINT,#BELL,#CR
         BYT "You pressed a non-alphanumeric"
         BYT " character"
         BYT CR,CR,0
         JMP SETLOOP
;
;
ISALPHA  CSP PRINT,#CR,#CR
         BYT "You entered an alphabetic character"
         BYT CR,CR,0
         JMP SETLOOP
;
ISNUMRIC CSP PRINT,#CR,#CR
         BYT "You entered a numeric character"
         BYT CR,CR,0
         JMP SETLOOP
;
;
;
;
;
;
;
;**********************************
;
;
; Demonstrate the NOTINSET routine
; here.
;
NOTSTEXP JSR HOME
NOTSTLP  CSP PRINT
         BYT "By typing a non-alphanumeric",CR
         BYT "character you can exit this routine"
         BYT CR,0
         JSR GETC
         CMP #"a"
         BLT >0
         AND #$DF
;
^0       CSP NOTINSET
         STR "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
         ADR MENULOOP
         JMP NOTSTLP
;
;
;
;**********************************
;
; Variable declaration
;
SELCTVAR ADR 0
         END